import { createRouter, createWebHashHistory } from 'vue-router'
import Login from '../Login.vue'
import Home from '../Home.vue'
import NotFound from '../NotFound.vue'

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      name: 'Login',
      component: Login
    },
    {
      path: '/home/:urlPath',
      name: 'Home',
      meta: { label: 'Home' },
      component: Home,
      beforeEnter: (to, from) => {
        if (to.params.urlPath !== 'comp1') {
          return { name: 'NotFound' }
        }
      }
    },
    {
      path: '/404',
      name: 'NotFound',
      component: NotFound
    }
  ]
})

router.beforeEach((to, from) => {
  console.log('beforeEach =>')
})

router.afterEach((to, from) => {
  console.log('afterEach =>')
})

router.beforeResolve((to, from) => {
  console.log('beforeResolve =>')
})

export default router;
